 <div class="pageheader">
      <h2><i class="fa fa-home"></i> Check Exam </h2>
    </div>
    <style type="text/css">
	
		.btn-success {
  background-color: #62BE66!important;
  color: #fff!important;

	}
	.btn-success:hover {
  background-color: #419E45;
}
.required_html {
    display: block!important;
    margin-top: -117px!important;
	    visibility: hidden;
}
	</style>
    <div class="contentpanel">
       
      <div class="panel panel-default">
        <div class="panel-body">
		<div class="clearfix mb30"></div>
           <!-- **shipping-address - Starts** -->
                                      <!-- **checkout - Starts** -->
                        <form name="checkout" method="post" class="checkout" action="<?php echo site_url("teacher").'/'.$this->uri->segment(2); ?>/submit_exam">
                          <div class="shipping_address woocommerce">
											
										<div class="form-row form-row-wide address-field update_totals_on_change upload-form" id="shipping_country_field">
												<h4 class="aligncenter"> <strong> Question Palette </strong></h4>
											<input type="hidden" name="exam_id" value="<?=$exam_id;?>" />
											<input type="hidden" name="student_id" value="<?=$student_id;?>" />											
											<!-- **pagination - Starts** -->  
											<div class="pagination">
												<ul>
													<?php 
													$i = 1;
													$questions = $this->db->get_where("submitted_by_students",array("exam_id"=>$exam_id,"student_id"=>$student_id))->result_array(); 
													foreach($questions as $question){
													?>
													<li><a data-href="#<?=$i;?>" class="click_me" href="#"><?=$i;?></a></li>	
													<?php $i++; } ?>
												</ul>
											</div> <!-- **pagination - Ends** -->
											
												<div class="clear"></div>
			
										</div>
										<?php 
										$i = 1;
										end($questions);
										$last_key = key($questions);
										foreach($questions as $key=>$question){											
													 ?>
											<div class="howdy form-row form-row-wide address-field update_totals_on_change upload-form <?php if( $key == $last_key) {echo "last_here";} ?>" style="<?php  if($key == 0){ echo "display:block";}else{echo "display:none";}?>" id="<?=$i;?>">
												<p> <strong><?=$i;?>.) </strong> <?=$question["question"]?> ?</p>
												<div id="payment">
													<ul class="payment_methods methods">
													<input type="hidden" name="question_type[<?=$question["id"];?>]" value="<?=$question["question_type"]?>" >
													<input type="hidden" name="question[<?=$question["id"];?>]" value="<?=$question["question"]?>" >
													<?php if($question["question_type"] == "true_false"){?>
													<li class="payment_method_bacs">
															<input id="option1[<?=$question["id"];?>]" type="radio" <?php if($question["answer"] == "true") {echo "checked";}?> class="input-radio" name="answer[<?=$question["id"];?>]" value="true" data-order_button_text="">
															<label for="option1[<?=$question["id"];?>]"><span></span> True </label>
														</li>
														<li class="payment_method_bacs">
															<input id="option2[<?=$question["id"];?>]" type="radio" class="input-radio" <?php if($question["answer"] == "false") {echo "checked";}?> name="answer[<?=$question["id"];?>]" value="false" data-order_button_text="">
															<label for="option2[<?=$question["id"];?>]"><span></span> False </label>
														</li>
													<?php }
													elseif($question["question_type"] == "multiple"){
														$j = 0;
														$answers = $this->db->get_where("tbl_exam_answers",array("question_id"=>$question["question_id"]))->result_array();
														foreach($answers as $key => $answer)
														{
															$answers_checked = explode(",",$question["answer"]);
															$answers_checked = array_filter($answers_checked);
															?>
															
														<li class="payment_method_bacs">
															<input id="option1[<?=$question["id"];?>][<?=$key?>]" type="radio" <?php if(in_array($answer["id"],$answers_checked )){echo "checked";} ?>  class="input-radio" name="answer[<?=$question["id"];?>][<?=$j?>]" value="<?=$answer["id"]?>" data-order_button_text="">
															<label for="option1[<?=$question["id"];?>][<?=$key?>]"><span></span>  <?=$answer["answer_text"]?></label>
														</li>
															<?php
															$j++;
														}
														?>
														<div class="alert alert-info" role="alert">
																<a type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only"></span></a>
																<strong>Note !</strong> You can select more then 1 option for this question.
															</div>
														<?php
													}
													elseif($question["question_type"] == "single"){
														$answers = $this->db->get_where("tbl_exam_answers",array("question_id"=>$question["question_id"]))->result_array();
														foreach($answers as $key=>$answer)
														{
															?>
														<li class="payment_method_bacs">
															<input id="option1[<?=$question["id"];?>][<?=$key?>]" <?php if($question["answer"] == $answer["id"]) {echo "checked";}?> type="radio" class="input-radio" name="answer[<?=$question["id"];?>]" value="<?=$answer["id"]?>" data-order_button_text="">
															<label for="option1[<?=$question["id"];?>][<?=$key?>]"><span></span>  <?=$answer["answer_text"]?></label>
														</li>
															<?php
														}
													}
													elseif($question["question_type"] == "subjective"){?>
															<textarea class="form-control post" name="answer[<?=$question["id"];?>]" ><?=$question["answer"]?></textarea>
															<?php
													}
													?>
													</ul>
												</div>
												<div class="col-md-12">
													<textarea class="form-control required_html post" name="answer_comment[<?=$question["id"];?>]"></textarea>
												</div>
												<div class="clear"></div>
			
											</div>
										<?php $i++;
										} ?>
										<br/>	
										<div class="row">
											<input type="button" class="button btn-success nxt_button" name="update_cart" value="Next Question" style="margin-left: 15px;">
											<input type="submit" class="button btn-success" name="update_cart" value="Save & Quit" style="margin-left: 15px;">
                                        </div> <!-- **shipping_address - Ends** --> 
                                        
										</div> <!-- **shipping_address - Ends** --> 
										</form>
          
        </div><!-- panel-body -->
      </div><!-- panel -->
        
    </div><!-- contentpanel -->
    
  </div><!-- mainpanel -->
 
  
</section>


<script src="<?php echo base_url();?>adm/js/jquery-1.10.2.min.js"></script>
<script src="<?php echo base_url();?>adm/js/jquery-migrate-1.2.1.min.js"></script>
<script src="<?php echo base_url();?>adm/js/bootstrap.min.js"></script>
<script src="<?php echo base_url();?>adm/js/modernizr.min.js"></script>
<script src="<?php echo base_url();?>adm/js/jquery.sparkline.min.js"></script>
<script src="<?php echo base_url();?>adm/js/toggles.min.js"></script>
<script src="<?php echo base_url();?>adm/js/jquery.cookie.js"></script>
<script src="<?php echo base_url();?>adm/js/jquery.datatables.min.js"></script>
<script src="<?php echo base_url();?>adm/js/select2.min.js"></script>
	<script src="<?php echo base_url();?>adm/js/jquery.wysiwyg.js"></script>
<script src="<?php echo base_url();?>adm/js/custom.js"></script>
<script>
  jQuery(document).ready(function() {
    jQuery(".input-radio").change(function(e){
		  var id = $(this).parent().parent().parent().parent().attr("id");
		  $("[data-href='#"+ id +"']").addClass("btn-success");
	  });
	 jQuery('.click_me').click(function(e){
			var href = $(this).attr("data-href");
			$(".howdy").css({'display':'none'});
			$(href).css({'display':'block'});
			$( "" ).removeClass( "myClass noClass" ).addClass( "yourClass" );
			return false;
		});
    jQuery('#table1').dataTable();
    
    jQuery('#table2').dataTable({
      "sPaginationType": "full_numbers"
    });
    
    // Chosen Select
    jQuery("select").select2();
    
    // Delete row in a table
    jQuery('.delete-row').click(function(){
      var c = confirm("Continue delete?");
      if(c)
        jQuery(this).closest('tr').fadeOut(function(){
          jQuery(this).remove();
        });
        
        return false;
    });
    
    // Show aciton upon row hover
    jQuery('.table-hidaction tbody tr').hover(function(){
      jQuery(this).find('.table-action-hide a').animate({opacity: 1});
    },function(){
      jQuery(this).find('.table-action-hide a').animate({opacity: 0});
    });
  jQuery('.post').wysiwyg({
          controls: {
              html: {visible: true},
              h1: {visible: false},
              h2: {visible: false},
              h3: {visible: false},
              code: {visible: false },
              createLink: {visible: false},
              unLink: {visible: true},
              insertImage: {visible: false},
              insertTable: {visible: false},
              insertHorizontalRule: {visible: false},
              subscript: {visible: true},
              superscript: {visible: true},
              insertOrderedList: {visible: false},
              insertUnorderedList: {visible: false},
              indent: {visible: true},
              outdent: {visible: true},
              undo: {visible: true},
              redo: {visible: true},
              justifyRight: {visible: true},
              justifyLeft: {visible: true},
              justifyFull: {visible: true},
              justifyCenter: {visible: true}
          },
		  css : { fontFamily: 'Arial, Tahoma', fontSize : '13px', color : '#9fa8b0'},
          initialContent: ""
      });
	  jQuery('.post').wysiwyg('focus');
  
  });
  	function foo(){
			
				jQuery('.last_here').each(function(){
					if(jQuery(this).is(':visible')){
						jQuery(".nxt_button").prop("disabled", true);
					}
					else
					{
						jQuery(".nxt_button").prop("disabled", false);
					}
				});
		} 
window.setInterval(foo, 100);
</script>

</body>
</html>
